using DG.Tweening;
using UnityEngine;
using QFramework;

namespace QFramework.Monk
{
	public partial class FlyTextCanvas : ViewController
	{
		public static FlyTextCanvas Default;
		
		void Awake()
		{
			Default = this;
		}

		public void CreateFlyText(string text, Vector3 pos)
		{
			var flyText = FlyText.InstantiateWithParent(FlyTextRoot).Position(pos.x,pos.y).LocalScale(0).Show();
			flyText.text = text;
			var posY = pos.y;
			ActionKit.Lerp(0, 1f, 0.6f, dt =>
			{
				flyText.PositionY(posY + dt);
				flyText.LocalScale(dt*1.5f);

			}, () =>
			{
				flyText.gameObject.DestroySelfGracefully();
			}).Start(flyText);
			/*flyText.transform.DOMoveY(pos.y + 0.5f, 0.5f).SetEase(Ease.OutBack).OnComplete(() =>
			{
				// 检查对象是否仍然存在
				if (flyText != null && flyText.gameObject != null)
				{
					flyText.gameObject.DestroySelfGracefully();
				}
			});*/
		}
	}
}
